package Admin;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import javax.swing.JOptionPane;

import GroupClass.ConnectRMI;
import Project_etow.EtowInterface;

public class InsertBillPayment extends javax.swing.JDialog {

    public InsertBillPayment(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    private String checkinviinsrt;
    
    public String getCheckinviinsrt()
    {
        return checkinviinsrt;
    }

    public void setCheckinviinsrt(String checkinviinsrt)
    {
        this.checkinviinsrt = checkinviinsrt;
    }
    ConnectRMI connectRMI = new ConnectRMI();
    @SuppressWarnings("unchecked")
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        btsubmit = new javax.swing.JButton();
        btexit = new javax.swing.JButton();
        flsecuri = new javax.swing.JTextField();
        flclean = new javax.swing.JTextField();
        flwash = new javax.swing.JTextField();
        flmain = new javax.swing.JTextField();
        flpark = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Bill Payment");

        jLabel1.setText("Security");

        jLabel2.setText("Washing Rooms");

        jLabel3.setText("Clean Building Glasses");

        jLabel4.setText("Maintenance Elevator");

        jLabel5.setText("Amount Of Parking");

        btsubmit.setText("Submit");
        btsubmit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btsubmitActionPerformed(evt);
            }
        });

        btexit.setText("Exit");
        btexit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btexitActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(
                        layout.createSequentialGroup()
                                .addGroup(
                                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(
                                                        layout.createSequentialGroup().addGap(72, 72, 72)
                                                                .addComponent(btsubmit).addGap(35, 35, 35)
                                                                .addComponent(btexit))
                                                .addGroup(
                                                        layout.createSequentialGroup()
                                                                .addGroup(
                                                                        layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addGroup(
                                                                                        layout.createSequentialGroup()
                                                                                                .addGap(22, 22, 22)
                                                                                                .addGroup(
                                                                                                        layout.createParallelGroup(
                                                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                                                .addComponent(
                                                                                                                        jLabel5,
                                                                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                                                                .addComponent(
                                                                                                                        jLabel4,
                                                                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                                                                .addComponent(
                                                                                                                        jLabel3,
                                                                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                                                                .addComponent(
                                                                                                                        jLabel2,
                                                                                                                        javax.swing.GroupLayout.Alignment.TRAILING)))
                                                                                .addGroup(
                                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                                        layout.createSequentialGroup()
                                                                                                .addContainerGap()
                                                                                                .addComponent(jLabel1)))
                                                                .addGap(18, 18, 18)
                                                                .addGroup(
                                                                        layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(
                                                                                        flpark,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        165,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                .addComponent(
                                                                                        flmain,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        165,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                .addGroup(
                                                                                        layout.createParallelGroup(
                                                                                                javax.swing.GroupLayout.Alignment.TRAILING)
                                                                                                .addComponent(
                                                                                                        flwash,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                        163,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                .addComponent(
                                                                                                        flclean,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                        164,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                                .addComponent(
                                                                                                        flsecuri,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                        163,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addContainerGap(49, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup()
                        .addGap(15, 15, 15)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel1)
                                        .addComponent(flsecuri, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(flwash, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(flclean, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel4)
                                        .addComponent(flmain, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel5)
                                        .addComponent(flpark, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(btsubmit).addComponent(btexit))
                        .addContainerGap(20, Short.MAX_VALUE)));

        pack();
    }// </editor-fold>

    private void btsubmitActionPerformed(java.awt.event.ActionEvent evt) {
        try
        {

            EtowInterface obj = null;
            Registry registry = LocateRegistry.getRegistry(connectRMI.host, connectRMI.port);
            obj = (EtowInterface) registry.lookup(connectRMI.regis);
            
            String billPaymetSecurity  = flsecuri.getText();
            String billPaymetWashingRooms = flwash.getText();
            String billPaymetCleanBuildingGlasses = flclean.getText();
            String billPaymetMaintenanceElevator = flmain.getText();
            String billPaymetAmountOfParking = flpark.getText();
            
           
            String result = obj.InsertBillPayment(billPaymetSecurity, billPaymetWashingRooms, billPaymetCleanBuildingGlasses, billPaymetMaintenanceElevator, billPaymetAmountOfParking);
                
            if(result.equals("InsertSusscess"))
                {
                    JOptionPane.showMessageDialog(null, "Insert Successful");                    
                    setVisible(false);

                }else
                {
                    JOptionPane.showMessageDialog(null, "Insert Failed");
                }
            
        }catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }

    private void btexitActionPerformed(java.awt.event.ActionEvent evt) {
        setVisible(false);
        setCheckinviinsrt("close");
    }

    /**
     * @param args
     *            the command line arguments
     */
    public static void main(String args[]) {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(InsertBillPayment.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(InsertBillPayment.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(InsertBillPayment.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(InsertBillPayment.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        }
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                InsertBillPayment dialog = new InsertBillPayment(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e)
                    {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton    btexit;
    private javax.swing.JButton    btsubmit;
    private javax.swing.JTextField flclean;
    private javax.swing.JTextField flmain;
    private javax.swing.JTextField flpark;
    private javax.swing.JTextField flsecuri;
    private javax.swing.JTextField flwash;
    private javax.swing.JLabel     jLabel1;
    private javax.swing.JLabel     jLabel2;
    private javax.swing.JLabel     jLabel3;
    private javax.swing.JLabel     jLabel4;
    private javax.swing.JLabel     jLabel5;
    // End of variables declaration
}
